package test;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.KeyStroke;

public class MnemonicT extends JFrame {
	private int count = 0;
	private JButton button;

	public MnemonicT() {
		super("Mnemonic   Test ");
		setLayout(new FlowLayout());
		setSize(300, 200);
		button = new JButton("sss");
		button.setAction(new AbstractAction("ssd") {
			public void actionPerformed(ActionEvent e) {
				System.out.println("invoke");
			}
		});
		
		add(button);

		InputMap im = button.getInputMap(JButton.WHEN_IN_FOCUSED_WINDOW);
		im.put(KeyStroke.getKeyStroke("N"), "sss"); // 按CTRL+A
		button.getActionMap().put("sss", button.getAction());
	}

	public static void main(String[] args) {
		new MnemonicT().setVisible(true);
	}
}
